﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Medianamik.Globalization;
using NUnit.Framework;
using Medianamik.Globalization.Utilities;

namespace Medianamik.Tests.Unit.Globalization.Utilities
{
    [TestFixture]
    public class ResourceTest
    {
        private Resource _actualResource;
        [SetUp]
        public void Init()
        {
            _actualResource = new Resource("id", "fr-CA", "allo", "resourceSet", new DateTime(2009, 9, 1));
        }

        [Test]
        public void IsOlderThan_should_throw_NullArgumentException_when_parameter_is_null()
        {
            Assert.Throws<ArgumentNullException>(() => _actualResource.IsOlderThan(null));
        }

        [Test]
        public void IsOlderThan_should_return_true_when_actualResource_IsOlderThan_resourceToCompare()
        { 
            var resourceToCompare = new Resource("id2", "fr-CA", "allo 2", "resourceSet", new DateTime(2009, 9, 2));

            Assert.That(_actualResource.IsOlderThan(resourceToCompare), Is.EqualTo(true));
        }
        [Test]
        public void IsOlderThan_should_return_false_when_actualResource_is_newer_than_resourceToCompare()
        {
            var resourceToCompare = new Resource("id2", "fr-CA", "allo 2", "resourceSet", new DateTime(2009, 8, 1));

            Assert.That(_actualResource.IsOlderThan(resourceToCompare), Is.EqualTo(false));
        }
        [Test]
        public void IsOlderThan_should_return_true_when_actualResource_has_no_ModifiedOn()
        {
            var actualResource = new Resource("id2", "fr-CA", "allo 2", "resourceSet");
            var resourceToCompare = new Resource("id2", "fr-CA", "allo 2", "resourceSet", new DateTime(2009, 8, 1));

            Assert.That(actualResource.IsOlderThan(resourceToCompare), Is.EqualTo(true));
        }
        [Test]
        public void IsOlderThan_should_return_false_when_resourceToCompare_has_no_ModifiedOn()
        {
            var resourceToCompare = new Resource("id2", "fr-CA", "allo 2", "resourceSet");

            Assert.That(_actualResource.IsOlderThan(resourceToCompare), Is.EqualTo(false));
        }
        [Test]
        public void IsOlderThan_should_return_false_when_currentResource_and_resourceToCompare_has_no_ModifiedOn()
        {
            var actualResource = new Resource("id2", "fr-CA", "allo 2", "resourceSet");
            var resourceToCompare = new Resource("id2", "fr-CA", "allo 2", "resourceSet");

            Assert.That(actualResource.IsOlderThan(resourceToCompare), Is.EqualTo(false));
        }

        [Test]
        public void IsOlderThan_should_return_false_when_resourceToCompare_has_exact_same_ModifiedOn()
        {
            var actualResource = new Resource("id2", "fr-CA", "allo 2", "resourceSet", new DateTime(2009, 8, 1));
            var resourceToCompare = new Resource("id2", "fr-CA", "allo 2", "resourceSet", new DateTime(2009, 8, 1));

            Assert.That(actualResource.IsOlderThan(resourceToCompare), Is.EqualTo(false));
        }
    }
}